package com.shujia

object Demo12Extends {

  def main(args: Array[String]): Unit = {
    //创建对象
    val student = new Student("文科一班", "张三")
    student.print()
  }
}

class Person(name: String) {
  val _name: String = name

  def print(): Unit = {
    println("姓名：" + _name)
  }
}


/**
 * 类的继承
 * 会继承父类的属性和方法
 */
class Student(clazz: String, name: String) extends Person(name) {
  val _clazz: String = clazz

  //重写父类方法
  override def print(): Unit = {
    println("姓名：" + _name + " 班级：" + _clazz)
  }
}



